<template>
  <div id="app">
    <h2>测试题</h2>
    <SubjectItem @sum="sum" />
    <div>
      <FlagItem :arr="arr" />
    </div>
  </div>
</template>

<script>
import FlagItem from "./components/FlagItem.vue";
import SubjectItem from "./components/SubjectItem.vue";

export default {

  components: {
    FlagItem,
    SubjectItem,
  },

  data() {
    return {
      arr: [],
    };
  },
  methods: {
    sum(num1, num2) {
      if (num1 === num2) {
        this.arr.push({
          res: "正确",
        });
      } else if (num1 !== num2) {
        if (num2 === undefined) {
          this.arr.push({
            res: "未完成",
          });
        } else {
          this.arr.push({
            res: "错误",
          });
        }
      }
    },
  },
};
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>